﻿using MediumApi.Result;
using MediumApi.Service;
using MediumApi.Tools;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using static MediumApi.Param.AppParam;
using static MediumApi.Result.AppResult;

namespace MediumApi.Controllers
{
    /// <summary>
    /// app控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class WebController : BaseController
    {

        private readonly AppService _appService;
        private readonly ConsoleService _consoleService;
        private readonly string _tempFolder;
        public WebController(AppService appService, ConsoleService consoleService, IWebHostEnvironment env)
        {
            _appService = appService;
            _consoleService = consoleService;
            _tempFolder = Path.Combine(env.ContentRootPath, "Temp");
            Directory.CreateDirectory(_tempFolder);
        }
        /// <summary>
        /// 查询频道列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List<SelectWebChannelListResult>))]
        public async Task<OperateResult> SelectWebChannelList()
        {
            string UserId = "";
            if (string.IsNullOrEmpty(this.UserID))
            {
                UserId = "1";
            }
            else
            {
                UserId = this.UserID;
            }
            return Success(await _consoleService.SelectWebChannelList(UserId));
        }
    }
}
